package com.dayang.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dayang.dao.BaseDAO;
import com.dayang.model.Client;
import com.dayang.service.ClientService;

@Service("clientService")
public class ClientServiceImpl implements ClientService{
	
	@Autowired
	private BaseDAO<Client> baseDAO;

	@Override
	public Client createClient(Client client) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Client updateClient(Client client) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deleteClient(Long clientId) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Client findOne(Long clientId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Client> findAll() {
		// TODO Auto-generated method stub
		return baseDAO.findAll(Client.class);
	}

	@Override
	public Client findByClientId(String clientId) {
		Map<String,Object> map = new HashMap<String, Object>();
		String hql=" from Client where clientId=:clientId";
		map.put("clientId", clientId);
		Query query =baseDAO.getHqlQuery(hql, map);
		if(query.list()!=null &&query.list().size()>0){
			return (Client) query.list().get(0);
		}else{
			return null;
		}
		 
		
	}

	@Override
	public Client findByClientSecret(String clientSecret) {
		// TODO Auto-generated method stub
		return null;
	}

}
